﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ReadNews : System.Web.UI.Page
{
    public string strTitle = "";
    public string strnewsMan = "";
    public string strAddTime = "";
    public string strContent = "";
    public string mune = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int pkID = int.Parse(Request.QueryString["ID"].ToString());
            string wtnewsType = SQL.GetData("select wtnewsType from wtnews where pkID=" + pkID + "", "wtnewsType");
            mune = wtnewsType;

            Repeater1.DataSource = SQL.GetDataTable("newsimage", "select * from newsimage where newsID=" + pkID + "");
            Repeater1.DataBind();

            Repeater2.DataSource = SQL.GetDataTable("nFileType", "select * from nFileType where newID=" + pkID + "");
            Repeater2.DataBind();

            rptMsg.DataSource = SQL.GetDataTable("wtnews", "select top 12 * from wtnews where wtnewsType='" + wtnewsType + "' and pkID!="+pkID+"order by wtnewsDate desc");
            rptMsg.DataBind();

            if (rptMsg.Items.Count == 0)
            {
                LabShowNO.Visible = true;
                LabShowNO.Text = "没有信息！";
            }

            strTitle = SQL.GetData("select wtnewsName from wtnews where pkID=" + pkID + "", "wtnewsName");
            strnewsMan = SQL.GetData("select wtnewsMan from wtnews where pkID=" + pkID + "", "wtnewsMan");
            strAddTime = SQL.GetData("select wtnewsDate from wtnews where pkID=" + pkID + "", "wtnewsDate");
            strContent = SQL.GetData("select wtnewsContent from wtnews where pkID=" + pkID + "", "wtnewsContent");
            Page.Header.Title = strTitle;
        }
    }
    protected void linkBut(object sender, EventArgs e)
    {
        LinkButton d = (LinkButton)sender;
        string productid = d.CommandArgument;
        string FileDownPlace = SQL.GetData("select FilePlace from nFileType where pkID=" + Convert.ToInt32(productid.ToString()) + "", "FilePlace");
        string fileName = SQL.GetData("select FileName from nFileType where pkID=" + Convert.ToInt32(productid.ToString()) + "", "FileName");
        FileOper.DownloadFile(Server.MapPath("LoadFile/") + "\\" + fileName);
    }
}
